﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class AdjustmentW
    {
        int adjVoucherID;
        int requestedBy;
        string requestedDate;
        int approvalBy;
        string approvalDate;
        string status;

        [DataMember]
        public int AdjVoucherID
        {
            get { return adjVoucherID; }
            set { adjVoucherID = value; }
        }

        [DataMember]
        public int RequestedBy
        {
            get { return requestedBy; }
            set { requestedBy = value; }
        }

        [DataMember]
        public string RequestedDate
        {
            get { return requestedDate; }
            set { requestedDate = value; }
        }

        [DataMember]
        public int ApprovalBy
        {
            get { return approvalBy; }
            set { approvalBy = value; }
        }

        [DataMember]
        public string ApprovalDate
        {
            get { return approvalDate; }
            set { approvalDate = value; }
        }

        [DataMember]
        public string Status
        {
            get { return status; }
            set { status = value; }
        }

        public static AdjustmentW convert(Adjustment adjustment)
        {
            AdjustmentW u = new AdjustmentW();

            u.AdjVoucherID = adjustment.AdjVoucherID;
            u.RequestedBy = adjustment.RequestedBy.GetValueOrDefault();
            u.RequestedDate = adjustment.RequestedDate.GetValueOrDefault().ToString();
            u.ApprovalBy = adjustment.ApprovalBy.GetValueOrDefault();
            u.ApprovalDate = adjustment.ApprovalDate.GetValueOrDefault().ToString();
            u.Status = adjustment.Status;

            return u;
        }

        public static List<AdjustmentW> convertList(List<Adjustment> list)
        {
            List<AdjustmentW> listW = new List<AdjustmentW>();

            foreach (Adjustment x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }
    }
}